//Copyright (C) 2009 Ron Coleman. Contact: ronncoleman@gmail.com
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 3 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
package org.workplicity.cia.model;

import java.util.ArrayList;
import java.util.List;
import org.workplicity.cia.util.WorkDate;

/**
 * This class is a user for administering user accounts.
 * @author Ron Coleman
 *
 */
public class User extends Entry {
    private static final long serialVersionUID = -6482381378329769196L;

    public enum Type {
        NA, ADMIN, SUPERVISOR, WORKER, REQUESTOR, VIEWER
    }

    protected Type type = Type.NA;
    protected List<Integer> serviceList = new ArrayList<Integer>();
    protected List<Integer> workSlateList = new ArrayList<Integer>();
    protected String logname;
    protected String password;
    protected WorkDate stamp = null;
    protected String firstName = "";
    protected String lastName = "";
    protected String phone = "";
    protected String email = "";
    protected boolean extAuth = false;

    /**
     * Constructor
     */
    public User() {
    }

    /**
     * Constructor
     * @param logname Log name
     */
    public User(String logname) {
        this.logname = logname;
    }

    /**
     * Constructor
     * @param logname Login name
     * @param password Login password
     */
    public User(String logname, String password) {
        this.logname = logname;
        this.password = password;
    }

    /**
     * Gets the phone
     * @return department
     */
    public String getPhone() {
        return phone;
    }

    /**
     * Sets the phone
     * @param phone Department
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * Gets the first name
     * @return first name
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Sets the first name
     * @param firstName First name
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Gets the last name
     * @return Last name
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * Sets the last name
     * @param lastName Last name
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * Gets the email address.
     * @return email
     */
    public String getEmail() {
        return email;
    }

    /**
     * Sets the email.
     * @param email Email address
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Tests whether user is externally authenticated.
     * @return
     */
    public boolean isExtAuth() {
        return extAuth;
    }

    /**
     * Sets external authentication.
     * @param extAuth True if externally authenticated.
     */
    public void setExtAuth(boolean extAuth) {
        this.extAuth = extAuth;
    }

    /**
     * Gets a string representation of the user.
     * @return User as a string
     */
    @Override
    public String toString() {
        return logname;
    }

    /**
     * Gets last time user accessed the system (set by app).
     * @return Date
     */
    public WorkDate getStamp() {
        return stamp;
    }

    /**
     * Sets last time user accessed the system (set by app).
     * @param stamp
     */
    public void setStamp(WorkDate stamp) {
        this.stamp = stamp;
    }

    public String getLogname() {
        return logname;
    }

    public void setLogname(String logname) {
        this.logname = logname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<Integer> getServiceList() {
        return serviceList;
    }

    public void setServiceList(List<Integer> serviceList) {
        this.serviceList = serviceList;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public List<Integer> getWorkSlateList() {
        return workSlateList;
    }

    public void setWorkSlateList(List<Integer> workSlateList) {
        this.workSlateList = workSlateList;
    }

}
